/*
 * SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
 *
 * SPDX-License-Identifier: MulanPSL-2.0
 */
#![allow(non_camel_case_types, non_snake_case, unused_mut)]

use crate::common::*;

//WRDE_NOCMD = (1 << 2),	/* Don't do command substitution.  */
pub const WRDE_NOCMD: libc::c_uint = 1 << 2;

extern "C" {
    fn __errno_location() -> *mut libc::c_int;
    fn dlsym(__handle: *mut libc::c_void, __name: *const libc::c_char) -> *mut libc::c_void;
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct sched_param {
    pub sched_priority: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct posix_spawnattr_t {
    pub __flags: libc::c_short,
    pub __pgrp: pid_t,
    pub __sd: sigset_t,
    pub __ss: sigset_t,
    pub __sp: sched_param,
    pub __policy: libc::c_int,
    pub __pad: [libc::c_int; 16],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct posix_spawn_file_actions_t {
    pub __allocated: libc::c_int,
    pub __used: libc::c_int,
    pub __actions: *mut __spawn_action,
    pub __pad: [libc::c_int; 16],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct wordexp_t {
    pub we_wordc: size_t,
    pub we_wordv: *mut *mut libc::c_char,
    pub we_offs: size_t,
}
pub type sudo_fn_wordexp_t =
    Option<unsafe extern "C" fn(*const libc::c_char, *mut wordexp_t, libc::c_int) -> libc::c_int>;

#[no_mangle]
pub unsafe fn execv(
    mut _a1: *const libc::c_char,
    mut _a2: *const *mut libc::c_char,
) -> libc::c_int {
    *__errno_location() = EACCES as libc::c_int;
    -(1 as libc::c_int)
}
#[no_mangle]
pub unsafe fn execvp(
    mut _a1: *const libc::c_char,
    mut _a2: *const *mut libc::c_char,
) -> libc::c_int {
    *__errno_location() = EACCES as libc::c_int;
    -(1 as libc::c_int)
}
#[no_mangle]
pub unsafe fn execve(
    mut _a1: *const libc::c_char,
    mut _a2: *const *mut libc::c_char,
    mut _a3: *const *mut libc::c_char,
) -> libc::c_int {
    *__errno_location() = EACCES as libc::c_int;
    -(1 as libc::c_int)
}
#[no_mangle]
pub unsafe fn execvpe(
    mut _a1: *const libc::c_char,
    mut _a2: *const *mut libc::c_char,
    mut _a3: *const *mut libc::c_char,
) -> libc::c_int {
    *__errno_location() = EACCES as libc::c_int;
    -(1 as libc::c_int)
}
#[no_mangle]
pub unsafe fn fexecve(
    mut _a1: libc::c_int,
    mut _a2: *const *mut libc::c_char,
    mut _a3: *const *mut libc::c_char,
) -> libc::c_int {
    *__errno_location() = EACCES as libc::c_int;
    -(1 as libc::c_int)
}
#[no_mangle]
pub unsafe fn posix_spawn(
    mut _a1: *mut pid_t,
    mut _a2: *const libc::c_char,
    mut _a3: *const posix_spawn_file_actions_t,
    mut _a4: *const posix_spawnattr_t,
    mut _a5: *const *mut libc::c_char,
    mut _a6: *const *mut libc::c_char,
) -> libc::c_int {
    *__errno_location() = EACCES as libc::c_int;
    -(1 as libc::c_int)
}
#[no_mangle]
pub unsafe fn posix_spawnp(
    mut _a1: *mut pid_t,
    mut _a2: *const libc::c_char,
    mut _a3: *const posix_spawn_file_actions_t,
    mut _a4: *const posix_spawnattr_t,
    mut _a5: *const *mut libc::c_char,
    mut _a6: *const *mut libc::c_char,
) -> libc::c_int {
    *__errno_location() = EACCES as libc::c_int;
    -(1 as libc::c_int)
}
#[no_mangle]
pub unsafe fn system(mut _a1: *const libc::c_char) -> libc::c_int {
    *__errno_location() = EACCES as libc::c_int;
    -(1 as libc::c_int)
}
#[no_mangle]
pub unsafe fn popen(mut _c: *const libc::c_char, mut _t: *const libc::c_char) -> *mut FILE {
    *__errno_location() = EACCES as libc::c_int;
    std::ptr::null_mut::<FILE>()
}
#[no_mangle]
pub unsafe fn wordexp(
    mut words: *const libc::c_char,
    mut we: *mut wordexp_t,
    mut flags: libc::c_int,
) -> libc::c_int {
    let mut fn_0: *mut libc::c_void = dlsym(
        -(1 as libc::c_long) as *mut libc::c_void,
        b"wordexp\0" as *const u8 as *const libc::c_char,
    );
    if fn_0.is_null() {
        *__errno_location() = EACCES as libc::c_int;
        return -(1 as libc::c_int);
    }
    (::core::mem::transmute::<*mut libc::c_void, sudo_fn_wordexp_t>(fn_0))
        .expect("non-null function pointer")(words, we, flags | WRDE_NOCMD as libc::c_int)
}
